package com.ssm.service.impl;

import com.ssm.entity.File;
import com.ssm.service.FileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.ui.Model;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.List;

/**
 * Created by bai on 2017/8/3.
 *
 */
@Component
public class CommonMethod {

    @Autowired(required = false)
    FileService fileService;

    /**
     * 获取文件列表的方法
     *
     * */
    public void getFileList(HttpServletRequest request, Model model){
        HttpSession session = request.getSession();
        String username = session.getAttribute("username").toString();
        //User user = userService.queryByUsername(username);

        List<File> fileList = fileService.queryByUserName(username);
        model.addAttribute("fileList",fileList);
    }
}
